package com.ita.osc.serviceImpl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.ita.osc.bean.Cart;
import com.ita.osc.bean.Dish;
import com.ita.osc.bean.Order;
import com.ita.osc.dao.OrderDao;
import com.ita.osc.daoImpl.OrderDaoImpl;
import com.ita.osc.service.CartManager;
import com.ita.osc.service.OrderManager;
import com.ita.osc.util.UUIDUtil;

public class OrderManagerImpl implements OrderManager {
	
	CartManager cartManager = new CartManagerImpl();
	OrderDao orderDao = new OrderDaoImpl();

	@Override
	public void checkoutCart(Cart cart) {
		// TODO Auto-generated method stub
		Order order = new Order(UUIDUtil.randomUUID(), cart.getUid(), new Date(), cartManager.getCartTotal(cart));
		orderDao.addOrder(order);
		orderDao.insertRelationTable(order.getOid(), cart.getCartList());
//		cartManager.clearCartByUserId(cart.getUid());
	}

	@Override
	public List<Order> listOrderByUId(String cuid) {
		// TODO Auto-generated method stub
		return orderDao.listOrderByUId(cuid);
	}

	@Override
	public Map<Dish, Integer> listDishByOrderId(String oid) {
		// TODO Auto-generated method stub
		return orderDao.listDishByOrderId(oid);
	}

}
